import { createParamDecorator, ExecutionContext } from "@nestjs/common";

import { RequestUser } from "../interfaces/request-user.interface";

export const CurrentUser = createParamDecorator(
  (data: unknown, context: ExecutionContext): RequestUser | undefined => {
    const request = context.switchToHttp().getRequest();
    return request.user as RequestUser | undefined;
  },
);
